Skip to content

Comments

Add AHT10 temperature and humidity sensor application#28

Open
pebri86 wants to merge 2 commits intoTactilityProject:mainfrom
pebri86:main
Open

Add AHT10 temperature and humidity sensor application#28
pebri86 wants to merge 2 commits intoTactilityProject:mainfrom
pebri86:main

Conversation

@pebri86
Copy link

@pebri86 pebri86 commented Feb 23, 2026

Summary by CodeRabbit

  • New Features

    • Added an AHT10 Sensor app that displays real-time temperature and humidity readings with a visual temperature gauge on the interface.
  • Chores

    • Updated build configuration and project settings.

@coderabbitai
Copy link

coderabbitai bot commented Feb 23, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new AHT10 Sensor application to the codebase. The addition includes a complete driver implementation (aht10.c/aht10.h) that interfaces with an I2C-connected AHT10 humidity and temperature sensor, providing initialization and read functionality. A main application file uses LVGL to display sensor readings via a circular arc and text labels. Build configuration files (CMakeLists.txt) integrate the new app into the ESP-IDF and Tactility SDK build system. A manifest.properties file declares the application metadata. The .gitignore file is updated to exclude the .cache directory.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately describes the main change: adding a new AHT10 sensor application with temperature and humidity functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
Apps/AHT10Sensor/main/CMakeLists.txt (1)

1-1: GLOB_RECURSE won't auto-detect new source files.

When new .c files are added under Source/, CMake won't re-run automatically — the developer must manually retrigger configuration. Consider listing sources explicitly or adding a comment instructing contributors to retrigger CMake.

Comment on lines +15 to +19
static bool find_i2c(struct Device* dev, void* ctx)
{
s_i2c = dev;
return false;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

find_i2c always selects the first I2C controller found.

On hardware with multiple I2C buses (e.g., a bus dedicated to a display and another to sensors), the AHT10 may not be on the first controller discovered. Consider accepting an I2C bus index or identifier via ctx (already available as the callback parameter) to allow callers to specify the intended bus.

pdMS_TO_TICKS(100)) != ERROR_NONE)
return false;

vTaskDelay(pdMS_TO_TICKS(80));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

vTaskDelay(80 ms) inside an LVGL timer callback blocks the LVGL task.

The call chain is lv_timer_create(sensor_update)sensor_updateaht10_readvTaskDelay(pdMS_TO_TICKS(80)). LVGL timers fire within the LVGL task; blocking that task for 80 ms every 2 seconds stalls all LVGL rendering and event processing for that window, causing periodic UI freezes.

The recommended fix is to decouple the I2C read from the LVGL thread — either dedicate a FreeRTOS task to sensor reading and share results with the LVGL thread via a mutex-protected struct, or split the read into a two-step state machine (trigger in one timer tick, read in the next after 80 ms has elapsed).

Comment on lines +77 to +85
uint8_t data[6];

if (i2c_controller_read(
s_i2c,
AHT10_ADDR,
data,
sizeof(data),
pdMS_TO_TICKS(100)) != ERROR_NONE)
return false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Status byte (data[0]) is never checked before parsing measurement data.

Per the AHT10 datasheet, byte 0 of the response contains the status register:

  • Bit 7 (busy flag) — 1 means measurement is still in progress; data in bytes 1–5 is invalid.
  • Bit 3 (calibration flag) — 0 means the sensor is uncalibrated; readings are unreliable.

Skipping these checks means that if the sensor is still busy (however unlikely after 80 ms) or uncalibrated, corrupt values are silently written to *humidity and *temperature.

🛡️ Proposed fix
     if (i2c_controller_read(
             s_i2c,
             AHT10_ADDR,
             data,
             sizeof(data),
             pdMS_TO_TICKS(100)) != ERROR_NONE)
         return false;

+    // Verify sensor is not busy and is calibrated
+    if ((data[0] & 0x80) || !(data[0] & 0x08))
+        return false;
+
     uint32_t raw_h =
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uint8_t data[6];
if (i2c_controller_read(
s_i2c,
AHT10_ADDR,
data,
sizeof(data),
pdMS_TO_TICKS(100)) != ERROR_NONE)
return false;
uint8_t data[6];
if (i2c_controller_read(
s_i2c,
AHT10_ADDR,
data,
sizeof(data),
pdMS_TO_TICKS(100)) != ERROR_NONE)
return false;
// Verify sensor is not busy and is calibrated
if ((data[0] & 0x80) || !(data[0] & 0x08))
return false;

Comment on lines +21 to +22
if (!label_temp || !label_hum)
return;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

arc_temp missing from the null guard.

label_temp and label_hum are guarded but arc_temp is used on line 32 without a null check. While onHideApp deletes the timer before nulling the pointer (making this safe today), the guard is inconsistent and becomes a latent NPE if the cleanup order ever changes.

🛡️ Proposed fix
-    if (!label_temp || !label_hum)
+    if (!arc_temp || !label_temp || !label_hum)
         return;

lv_obj_set_size(arc_temp, 200, 200);
lv_obj_align(arc_temp, LV_ALIGN_CENTER, 0, 30);

lv_arc_set_range(arc_temp, 0, 50);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Arc range 0–50°C is too narrow for the AHT10's full output range.

The AHT10 measures from −40°C to +85°C. Temperatures outside 0–50°C will be silently clamped by lv_arc_set_value, showing incorrect arc position while the label displays the true value — creating a confusing visual mismatch.

lv_label_set_text(label_hum, "Humidity --%");
lv_obj_align(label_hum, LV_ALIGN_CENTER, 0, 60);

aht10_init();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

aht10_init() return value silently discarded.

If the sensor is absent or I2C setup fails, the app proceeds normally — the timer fires, aht10_read fails immediately, and the UI remains stuck on placeholder values with no indication of failure. At minimum, consider logging the error or displaying an error state in the UI.

@pebri86 pebri86 changed the title Merge branch 'main' of https://github.com/TactilityProject/TactilityApps Add AHT10 temperature and humidity sensor application Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant